//
//  HttpVC.m
//  first
//
//  Created by 毕小强 on 16/11/30.
//  Copyright © 2016年 毕小强. All rights reserved.
//

#import "HttpVC.h"

@interface HttpVC ()<NSURLConnectionDelegate,NSURLConnectionDataDelegate>

@end

@implementation HttpVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSURL *url = [NSURL URLWithString:@"http://m2.qiushibaike.com/article/list/text?count=30&page=1&AdID=14314020462881C8509990"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    NSURLResponse *response = nil;
    NSError *error = nil;
    //NSData *receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    [NSURLConnection connectionWithRequest:request delegate:self];
    NSLog(@"%@",response);
    NSLog(@"%@",error);
    //NSArray *items = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingMutableContainers error:nil];
    //NSLog(@"%@",items);
}
#pragma mark NSURLConnectionDelegate
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
    NSArray *items = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    NSLog(@"----------%@",items);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
